/*
 * Project: BoboDesignPattern
 * 
 * File Created at 2019年12月5日
 * 
 * Copyright 2012 Greenline.com Corporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Greenline Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Greenline.com.
 */
package test.practice;

/**
 * @Type A20191205_bridge_builder
 * @Desc
 * @author 52489
 * @date 2019年12月5日
 * @Version V1.0
 */
public class A20191205_bridge_builder {

    abstract class Coumputer {
        Brand brand;

        /**
         * @param brand
         */
        public Coumputer(Brand brand) {
            this.brand = brand;
        }

        abstract void sale();
    }

    class NoteCoumputer extends Coumputer {

        /**
         * @param brand
         */
        public NoteCoumputer(Brand brand) {
            super(brand);
        }

        /*
         * (non-Javadoc)
         * 
         * @see practice.A20191205_bridge_builder.Coumputer#sale()
         */
        @Override
        void sale() {
            brand.sale();
            System.out.println("笔记本电脑");
        }

    }

    interface Brand {
        void sale();
    }

    class LenovoBrand implements Brand {

        /*
         * (non-Javadoc)
         * 
         * @see practice.A20191205_bridge_builder.Brand#sale()
         */
        @Override
        public void sale() {
            System.out.println("联想电脑");
        }

    }

    class Catcher {
        String catchModel;
        String config;
        String beginUrl;

        public String getCatchModel() {
            return catchModel;
        }

        public void setCatchModel(String catchModel) {
            this.catchModel = catchModel;
        }

        public String getConfig() {
            return config;
        }

        public void setConfig(String config) {
            this.config = config;
        }

        public String getBeginUrl() {
            return beginUrl;
        }

        public void setBeginUrl(String beginUrl) {
            this.beginUrl = beginUrl;
        }

    }

    interface CatcherBuilder {

        void buildCatchModel();

        void buildConfig();

        void buildBeginUrl();
    }

    class CatchAndPushModel implements CatcherBuilder {

        Catcher catcher;

        /**
         * @param catcher
         */
        public CatchAndPushModel(Catcher catcher) {
            this.catcher = catcher;
        }

        /*
         * (non-Javadoc)
         * 
         * @see
         * practice.A20191205_bridge_builder.CatcherBuilder#buildCatchModel()
         */
        @Override
        public void buildCatchModel() {
            catcher.setCatchModel("实时推送模式");
        }

        /*
         * (non-Javadoc)
         * 
         * @see practice.A20191205_bridge_builder.CatcherBuilder#buildConfig()
         */
        @Override
        public void buildConfig() {
            catcher.setConfig("实时推送配置");
        }

        /*
         * (non-Javadoc)
         * 
         * @see practice.A20191205_bridge_builder.CatcherBuilder#buildBeginUrl()
         */
        @Override
        public void buildBeginUrl() {
            catcher.setBeginUrl("url");
        }

    }

    interface CatcherDirector {
        void createCatcher();
    }

    class CatchAndPusModelDirctor implements CatcherDirector {

        CatcherBuilder catcherBuilder;

        /**
         * @param catcherBuilder
         */
        public CatchAndPusModelDirctor(CatcherBuilder catcherBuilder) {
            super();
            this.catcherBuilder = catcherBuilder;
        }

        /*
         * (non-Javadoc)
         * 
         * @see
         * practice.A20191205_bridge_builder.CatcherDirector#createCatcher()
         */
        @Override
        public void createCatcher() {
            catcherBuilder.buildBeginUrl();
            catcherBuilder.buildCatchModel();
            catcherBuilder.buildConfig();
        }

    }

    public static void main(String[] args) {
        // A20191205_bridge_builder.Brand lenovo = new
        // A20191205_bridge_builder().new LenovoBrand();
        // A20191205_bridge_builder.Coumputer noteCpt = new
        // A20191205_bridge_builder().new NoteCoumputer(lenovo);
        // noteCpt.sale();
        A20191205_bridge_builder.Catcher catcher = new A20191205_bridge_builder().new Catcher();
        A20191205_bridge_builder.CatcherBuilder catchAndPusModelBuilder = new A20191205_bridge_builder().new CatchAndPushModel(
                catcher);
        A20191205_bridge_builder.CatcherDirector director = new A20191205_bridge_builder().new CatchAndPusModelDirctor(
                catchAndPusModelBuilder);
        director.createCatcher();

        System.out.println(catcher.getCatchModel());

    }

}
